<?php

class BaseController extends Controller
{

    /**
     * Setup the layout used by the controller.
     *
     * @return void
     */
    protected function setupLayout()
    {
        if (! is_null($this->layout)) {
            $this->layout = View::make($this->layout);
        }
    }
    
    //取得所有菜单
    protected function getNav($num = 10){
    	return PostType::take($num)->get() ;
    }
    
    //取得最新文章
    protected function getNewPosts($num=5){
        $num = empty($num) ? 5 : intval($num) ;
    	return Post::orderBy('created_at', 'desc')->take($num)->get();
    }
    
    //取得最新评论所关联的文章
    protected function getCommentPosts($num=5){
        $num = empty($num) ? 5 : intval($num) ;
        return Comment::orderBy('created_at', 'desc')->take($num)->get();
    }
    
    
}